import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;


//特点，无序，没有下标，不能重复
public class Demo1Set {
    public static void main(String[] args) {

        Set <String> set=new HashSet<>();
        //1添加数据
        set.add("Apple");
        set.add("华为");
        set.add("小米");
        set.add("小米");
        System.out.println("数据个数："+set.size());
        System.out.println(set);

        //删除
        set.remove("小米");
        System.out.println(set.toString());

        //遍历【重点】

        for (Object object :
                set) {
            System.out.println(object);
        }
        System.out.println("迭代器遍历");
        Iterator iterator=set.iterator();
        while(iterator.hasNext())
        {
            System.out.println(iterator.next());
        }


        set.contains("小米");

    }
}
